package com.zzh.demo.core.common;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.List;

public class PageList<T> implements Serializable {

    private static final long serialVersionUID = -1428187732936978938L;

    /**
     * 记录总条数
     */
    private long total;

    /**
     * 当前页记录列表
     */
    private List<T> rows;


    public PageList() {
    }

    public PageList(List<T> rows) {
        if(rows instanceof Page) {
            Page page = (Page) rows;
            this.total = page.getTotal();
        } else {
            this.total = rows.size();
        }
        this.rows = rows;
    }

    private PageList(long totalCount, List<T> root) {
        this.total = totalCount;
        this.rows = root;
    }


    public long getTotal() {
        return total;
    }


    public void setTotal(long total) {
        this.total = total;
    }


    public List<T> getRows() {
        return rows;
    }


    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
